package com.ycsj.goldmedalnewconcept.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ToggleButton;

import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.utils.SPUtil;

//消息提醒设置
public class MsgSettingActivity extends Activity implements OnClickListener {

	private ImageView iv_back;

	private ToggleButton tbt_msg1;
	private ToggleButton tbt_msg2;
	private boolean msg1;
	private boolean msg2;

	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_msgsetting);
		initView();
		setOnListener();
		initData();
	}

	private void initView() {
		// TODO Auto-generated method stub
		iv_back = (ImageView) findViewById(R.id.iv_back);
		tbt_msg1 = (ToggleButton) findViewById(R.id.tbt_msg1);
		tbt_msg2 = (ToggleButton) findViewById(R.id.tbt_msg2);
	}

	private void initData() {
		// TODO Auto-generated method stub
		msg1 = SPUtil.getBoolean(MsgSettingActivity.this, "msg1", false);
		msg2 = SPUtil.getBoolean(MsgSettingActivity.this, "msg2", false);

		
		if(msg1){
			tbt_msg1.setChecked(true);
		}
		if(msg2){
			tbt_msg2.setChecked(true);
		}
		
		
	}

	private void setOnListener() {
		// TODO Auto-generated method stub
		iv_back.setOnClickListener(this);

		tbt_msg1.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				Log.e("test1", isChecked + "");
				SPUtil.putBoolean(MsgSettingActivity.this, "msg1", isChecked);

			}
		});
		tbt_msg2.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				Log.e("test2", isChecked + "");
				SPUtil.putBoolean(MsgSettingActivity.this, "msg2", isChecked);
			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.iv_back:
			finish();
			break;

		}
	}

}
